package entities;

import java.awt.Color;

/** Life's constructor.
 * @author Team 1
 *
 */
@SuppressWarnings("serial")
public class Life extends Entity {
	
	private int livesNumber = 3;		//The initial life's value.
	
	/** The life's constructor.
	 * @param x : the entity's upper-left corner's x coordinate.
	 * @param y : the entity's upper-left corner's y coordinate.
	 * @param xScale : the x resize scale. If it's lower than one it reduces the images original width, increase it otherwise.
	 * @param yScale : the y resize scale. If it's lower than one it reduces the images original height, increase it otherwise.
	 */
	public Life(int x, int y, float xScale, float yScale) {
		super(x, y);
		this.width = Math.round(130 * xScale);
		this.height = Math.round(15 * yScale);
		this.setText("Lifes: " + livesNumber);
		this.setForeground(Color.WHITE);
		this.setBounds(x, y, width, height);
	}
	
	public Life(int x, int y, int lives, float xScale, float yScale) {
		super(x, y);
		this.width = Math.round(130 * xScale);
		this.height = Math.round(15 * yScale);
		this.livesNumber = lives;
		this.setText("Lifes: " + livesNumber);
		this.setForeground(Color.WHITE);
		this.setBounds(x, y, width, height);
	}
	
	/** Gets life number
	 * @return lifesNumber : lifesNumber's value.
	 */
	public int getLives() {
		return livesNumber;
	}
	/** Sets and Shows the life number.
	 * @param lifesNumber : lifesNumber's value.
	 */
	public void setLives(int livesNumber) {
		if(livesNumber > -2) {
			this.livesNumber = livesNumber;
			setText("Lifes: " + livesNumber);
		} else {
			this.livesNumber = Integer.MAX_VALUE;
			setText("Lifes: " + Integer.MAX_VALUE);
		}
	}
	
	/** Return the life's width for all resolution giving the windows width divided by 1280.
	 * @param xScale : The windows horizontal proportion value.
	 * @return The value of the ball's width depending on the horizontal scale.
	 */
	public static int getWidth(float xScale) {
		return Math.round(130 * xScale);
	}
	
	/**Return the life's height for all resolution giving the windows height divided by 720.
	 * @param yScale : The windows vertical proportion value.
	 * @return The value of the ball's height depending on the vertical scale.
	 */
	public static int getHeight(float yScale) {
		return Math.round(15 * yScale);
	}
}
